Logging tweaks
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 21 Sep 2008 08:28:21 +0000 (08:28 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 21 Sep 2008 08:28:21 +0000 (08:28 +0000)
includes/db/Database.php
includes/db/LoadBalancer.php

index 0bd77ea..1fa1707 100644 (file)
@@ -376,24 +376,21 @@ class Database {
                                $error = $phpError;
                        }
                        wfLogDBError( "Error connecting to {$this->mServer}: $error\n" );
+                       wfDebug( "DB connection error\n" );
+                       wfDebug( "Server: $server, User: $user, Password: " .
+                               substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" );
+                       $success = false;
                }
                
                wfProfileOut("dbconnect-$server");
 
-               if ( $dbName != '' ) {
-                       if ( $this->mConn !== false ) {
-                               $success = @/**/mysql_select_db( $dbName, $this->mConn );
-                               if ( !$success ) {
-                                       $error = "Error selecting database $dbName on server {$this->mServer} " .
-                                               "from client host {$wguname['nodename']}\n";
-                                       wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n");
-                                       wfDebug( $error );
-                               }
-                       } else {
-                               wfDebug( "DB connection error\n" );
-                               wfDebug( "Server: $server, User: $user, Password: " .
-                                       substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" );
-                               $success = false;
+               if ( $dbName != '' && $this->mConn !== false ) {
+                       $success = @/**/mysql_select_db( $dbName, $this->mConn );
+                       if ( !$success ) {
+                               $error = "Error selecting database $dbName on server {$this->mServer} " .
+                                       "from client host {$wguname['nodename']}\n";
+                               wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n");
+                               wfDebug( $error );
                        }
                } else {
                        # Delay USE query
index cfea8b3..d0a7343 100644 (file)
@@ -663,6 +663,7 @@ class LoadBalancer {
                        $reporting = true;
                        if ( !is_object( $conn ) ) {
                                // No last connection, probably due to all servers being too busy
+                               wfLogDBError( "LB failure with no last connection\n" );
                                $conn = new Database;
                                if ( $this->mFailFunction ) {
                                        $conn->failFunction( $this->mFailFunction );
@@ -678,6 +679,7 @@ class LoadBalancer {
                                        $conn->failFunction( false );
                                }
                                $server = $conn->getProperty( 'mServer' );
+                               wfLogDBError( "Connection error: {$this->mLastError} ({$server})\n" );
                                $conn->reportConnectionError( "{$this->mLastError} ({$server})" );
                        }
                        $reporting = false;